home *** CD-ROM | disk | FTP | other *** search
- property spr, iniX, iniY
- property anima, marca
- property periodoX, deslocamentoX
- property periodoY, deslocamentoY
- property ampX, ampY
- property metodo
- property pulo
- property memoria, limitado
-
- on getBehaviorDescription
- return "Movimento senoidal"
- end
-
- on getPropertyDescriptionList
- set p_list = [ ¬
- #periodoX: [ #comment: "Periodo do movimento X",¬
- #format: #integer,¬
- #default: 600 ],¬
- #deslocamentoX: [ #comment: "Deslocamento do movimento X",¬
- #format: #integer,¬
- #default: 0 ],¬
- #ampX: [ #comment: "Amplitude maxima do movimento X",¬
- #format: #integer,¬
- #default: 30 ],¬
- #periodoY: [ #comment: "Periodo do movimento Y",¬
- #format: #integer,¬
- #default: 600 ],¬
- #deslocamentoY: [ #comment: "Deslocamento do movimento Y",¬
- #format: #integer,¬
- #default: 0 ],¬
- #ampY: [ #comment: "Amplitude maxima do movimento Y",¬
- #format: #integer,¬
- #default: 30 ],¬
- #metodo: [ #comment: "Extras",¬
- #format: #integer,¬
- #default: 0 ],¬
- #memoria: [ #comment: "Limite minimo de memoria para movimento",¬
- #format: #integer,¬
- #default: 0 ]¬
- ]
- return p_list
- end
-
- on beginSprite me
- set spr = the spriteNum of me
- set iniX = the locH of sprite spr
- set iniY = the locV of sprite spr
- set anima = 0
- set pulo = random(periodoX)
-
- global myMemSize
- if myMemSize < memoria * 1024 * 1024 then
- set limitado = true
- else
- set limitado = false
- end if
-
- end
-
- on idleSprite me
- if limitado then return
-
- if anima = 0 then
- set anima = the timer
- else
- global gMustUpdate
- set tmp = the timer - anima
- if metodo = 1 then
- if tmp > pulo then
- set anima = anima - random(periodoX)
- set tmp = the timer - anima
- set pulo = 0
- end if
- if tmp > periodoX and tmp > pulo then
- set pulo = random(periodoX)
- set anima = the timer + periodoX
- end if
- end if
- if ampX <> 0 then
- set tmpX = (tmp + deslocamentoX) mod periodoX
- set tmpX = float(tmpX) / periodoX * 2.0 * pi
- set x = iniX + Integer(sin(tmpX) * ampX)
- if the locH of sprite spr <> x then
- set the locH of sprite spr to x
- set gMustUpdate to true
- end if
- end if
- if ampY <> 0 then
- set tmpY = (tmp + deslocamentoY) mod periodoY
- set tmpY = float(tmpY) / periodoY * 2 * pi
- set y = iniY + Integer(sin(tmpY) * ampY)
- if the locV of sprite spr <> y then
- set the locV of sprite spr to y
- set gMustUpdate to true
- end if
- end if
- end if
- end
-